(function($)
{
	$(document).ready(function() {

		$('.sidebar-switch').click(function()
		{	
			switchSidebar(this.getAttribute('rel'));
			return false;
		});

		$('.skin-switch').click(function()
		{	
			switchSkin(this.getAttribute('rel'));
			return false;
		});

		$('.header-switch').click(function()
		{	
			switchHeader(this.getAttribute('rel'));
			return false;
		});
	});

	function switchSidebar(side) 
	{
		if (side == 'right') {
			$('#site-navigation').addClass('nav-expand');
			$('#wrapper').addClass('nav-expand');
			$('#masthead').removeClass('main-navigation-left').addClass('main-navigation-right');
			$('#site-navigation').removeClass('main-navigation-left').addClass('main-navigation-right');
			$('#wrapper').removeClass('main-navigation-left').addClass('main-navigation-right');
		} else if (side == 'left') {
			$('#site-navigation').addClass('nav-expand');
			$('#wrapper').addClass('nav-expand');
			$('#masthead').removeClass('main-navigation-right').addClass('main-navigation-left');
			$('#site-navigation').removeClass('main-navigation-right').addClass('main-navigation-left');
			$('#wrapper').removeClass('main-navigation-right').addClass('main-navigation-left');
		}
	}

	function switchSkin(skin)
	{	
		if (skin == 'none') {
			$("link[href*='skin-']").remove();
		} else {
			$('#site-navigation').addClass('nav-expand');
			$('#wrapper').addClass('nav-expand');
			$("link[href*='skin-']").remove();
			$('head').append('<link rel="stylesheet" href="http://demo.knacc.co/expressivo/wp-content/themes/expressivo/css/skin-' + skin + '.css" type="text/css" />');
		}

	}

	function switchHeader(layout) 
	{
		if (layout == 'header-1') {
			$('#masthead').attr('data-style','header-1');
		} else if (layout == 'header-2') {
			$('#masthead').attr('data-style', 'header-2');
		} else if (layout == 'header-3') {
			$('#masthead').attr('data-style', 'header-3');
		}
	}

})(jQuery);

// createCookie('style', styleName, 365);
// readCookie('style');

// Cookie functions
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}

// Customizr Panel
	jQuery('.demo-customizr .demo-icon').click(function() 
	{

		if (jQuery('.demo-customizr').hasClass("active")) 
		{
			jQuery('#site-navigation').removeClass('nav-expand');
			jQuery('#wrapper').removeClass('nav-expand');
			jQuery('.demo-customizr').animate({"left":"-180px"},function() 
			{
				jQuery('.demo-customizr').toggleClass("active");
			});						
		} else {
			jQuery('.demo-customizr').animate({"left":"0px"},function() 
			{
				jQuery('.demo-customizr').toggleClass("active");

			});			
		}
	});